package com.dhnsoft.util;

import java.awt.*;

/**
 * @Description
 * @ClassName MyUtil
 * @Author dhn
 * @date 2020.11.18 08:15
 * 工具类
 */
public class MyUtil {
    private MyUtil(){

    }
    /**
     * 随机数
     *
     * */
    public static final int getRandomNumber(int min,int max){
        return (int)(Math.random()*(max-min)+min);
    }
    /*
    * 等到随机颜色
    * */
    public static final Color getRandomColor(){
        int red=getRandomNumber(0,256);
        int blue=getRandomNumber(0,256);
        int green=getRandomNumber(0,256);
        return new Color(red,green,blue);
    }

    public static final boolean isCollide(int rectX,int rectY,int radius,int pointX,int pointY){
        //正方形中心点  x y轴的距离
        int disX = Math.abs(rectX - pointX);
        int disY = Math.abs(rectY - pointY);
        if(disX < radius && disY < radius){
            return true;
        }
        return false;
    }


    /**
     * 根据图片的资源路径创建加载图片对象
     * */
    public static final Image createImage(String path){
        return Toolkit.getDefaultToolkit().createImage(path);
    }





    private static final String[] NAMES={
            "行人","乐园","花草","人才","左手","目的","课文",
            "优点","年代","灰尘","沙子","小说","儿女","难题",
            "明星","本子","彩色","水珠","路灯","把握","房屋","心愿",
            "左边","新闻","早点","市场","雨点","细雨","书房","毛巾",
            "画家","元旦","绿豆","本领","起点","青菜","土豆","总结",
            "礼貌","右边","老虎","老鼠","猴子","树懒","斑马","小狗",
            "狐狸","狗熊","黑熊","大象","豹子","慶牛","狮子","熊猫",
            "疣猪","羚羊","驯鹿","考拉","屏牛","給翔","理程","海牛",
            "水獭","海豚","海象","刺猬","袋鼠","执狳","河马","海豹",
            "海狮","嬌垢","白虎","狸猫","水牛","山羊","绵羊","耗牛",
            "猿猴","松鼠","野猪","荣猪","廉鹿","花豹","野狼","灰狼",
            "蜂猴","無猴","叶猴","紫紹","紹熊","無狸","云豹","雪豹",
            "黑鹿","野马","慈鹿?","坡鹿","豚鹿","野牛","藏羚","河狂",
            "驼鹿","黄羊","兼羚","理羚","岩羊","盘羊","雪兔"
    };

    private static final String[] MODIFIY={
            "可爱","傻傻","萌萌","差差","笨笨","呆呆","美丽","聪明",
            "伶俐","狡猾","胖乎乎","粉嫩嫩","白胖胖","漂亮","可爱",
            "聪明","懂事","乖巧","淘气","淘气","顽劣","调皮","顽皮",
            "天真","可爱","无邪","单纯","纯洁","无暇","纯真","稚气","温润","好奇"
    };
    /*
    * 得到一个随机名字
    * */
    public static final String getRandomName(){
        return MODIFIY[getRandomNumber(0,MODIFIY.length)]+"的"+NAMES[getRandomNumber(0,NAMES.length)];
    }


}
